package com.iversonx.observer.example_1.v2;

import com.iversonx.observer.example_1.service.MinibusTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 **/
@Service
public class LotteryServiceV2 {
    
    @Autowired
    private MinibusTargetService minibusTargetService;
    
    @Autowired
    private EventManager eventManager;
    
    public void doDraw(String uId) {
        // 摇号
        String lottery = minibusTargetService.lottery(uId);
        
        // 事件通知
        eventManager.notifyMQEvent("记录⽤户 " + uId + " 摇号结果(MQ)：" + lottery);
        eventManager.notifySmsEvent("给⽤户 " + uId + " 发送短信通知(短信)：" + lottery);
    }
}
